$(function () {
    // var loading = weui.loading('loading', {
    //     className: 'custom-classname'
    // });
    var id = '_1',
        classify = Config.classify;
    // 使用搜索条
    weui.searchBar("#searchBar");
    // 默认显示首个分类目录
    for (var i = 0; i < classify[id].length; i++) {
        var item = '<a class="m-classify-item" href="list_goods.html?cid=' + classify[id][i].id + '"><img src="../img/classify/' + id.substring(1) + "/" + classify[id][i].id + '.png"><p>' + classify[id][i].title + "</p></a>";
        $(".m-classify-items").append(item);
    }
    loading.hide();
});
// 切换分类
$(document).on("click", "li", function () {
    var loading = weui.loading('loading', {
        className: 'custom-classname'
    });
    var id = $(this).parent().attr('data-id'),
        classify = Config.classify;
    // 设置样式
    $(".m-classify-title ul li").removeClass("m-search-title-active");
    $(this).addClass("m-search-title-active");
    // 切换分类内容
    $(".m-classify-items").empty();
    if (classify.hasOwnProperty(id)) {
        for (var i = 0; i < classify[id].length; i++) {
            var item = '<a class="m-classify-item" href="list_goods.html?cid=' + classify[id][i].id + '"><img src="../img/classify/' + id.substring(1) + "/" + classify[id][i].id + '.png"><p>' + classify[id][i].title + "</p></a>";
            $('.m-classify-items').append(item);
        }
    }
    loading.hide();
});

// 搜索按钮
$(document).on('click', '.m-search-bar', function() {
    location.href = 'search_goods.html';
});